import PageHeader from 'crates-io/components/page-header';
import TextContent from 'crates-io/components/text-content';

<template>
  <PageHeader @title='Data Access Policy' />

  <TextContent @boxed={{true}}>
    <p>
      crates.io provides several ways of accessing crate data and metadata, depending on what you specifically need.
      Please try them in the order below.
    </p>

    <h2 id='crate-index'><a href='#crate-index'>Crate index</a></h2>

    <p>
      The crates.io sparse index is available at
      <a href='https://index.crates.io'>index.crates.io</a>, which adheres to the
      <a href='https://doc.rust-lang.org/cargo/reference/registry-index.html'>Cargo index format</a>. The sparse index
      provides an extremely efficient way of accessing metadata on a single or small number of crates.
    </p>

    <p>
      Each index file provides newline delimited JSON metadata on all published versions of the crate, organised into
      <a href='https://doc.rust-lang.org/cargo/reference/registry-index.html#index-files'>index files</a>. For example,
      information on the
      <code>base64</code>
      crate can be found at
      <a href='https://index.crates.io/ba/se/base64'>https://index.crates.io/ba/se/base64</a>.
    </p>

    <p>
      No rate limits are required to use data from the sparse crate index.
    </p>

    <h3 id='legacy-git-index'><a href='#legacy-git-index'>Legacy Git crate index</a></h3>

    <p>
      Older versions of Cargo use the crate index provided in the
      <a href='https://github.com/rust-lang/crates.io-index'><code>rust-lang/crates.io-index</code>
        repository on GitHub</a>. This remains available for use, and may be a more efficient way of accessing crate
      metadata for projects that require most or all crates to be included than the sparse index.
    </p>

    <p>
      As the Git index is hosted on GitHub, GitHub's
      <a href='https://docs.github.com/en/site-policy/acceptable-use-policies/github-acceptable-use-policies'>Acceptable
        Use Policies</a>
      apply.
    </p>

    <h2 id='rss-feeds'><a href='#rss-feeds'>RSS feeds</a></h2>

    <p>
      crates.io provides a couple of RSS feeds that contain information on new crates and crate updates:
    </p>

    <ul>
      <li>
        <a href='https://static.crates.io/rss/crates.xml'>https://static.crates.io/rss/crates.xml</a>:<br />
        The latest new crates registered on crates.io (the past 60 minutes, but at least 50 new crates).
      </li>
      <li>
        <a href='https://static.crates.io/rss/updates.xml'>https://static.crates.io/rss/updates.xml</a>:<br />
        The latest version updates on crates.io (the past 60 minutes, but at least 100 versions).</li>
      <li>
        e.g.
        <a href='https://static.crates.io/rss/crates/serde.xml'>https://static.crates.io/rss/crates/serde.xml</a>:<br />
        The latest version updates of the serde crate (the past 24 hours, but at least 10 versions).</li>
    </ul>

    <h2 id='database-dumps'><a href='#database-dumps'>Database dumps</a></h2>

    <p>
      crates.io database dumps contain all information available through the crates.io API in a single download. They
      are updated every 24 hours.
    </p>

    <p>
      The latest dump is available at the address
      <a href='https://static.crates.io/db-dump.tar.gz'>https://static.crates.io/db-dump.tar.gz</a>. Information on
      using the dump is contained in the tarball. You can find the changelog for database dumps in
      <a href='https://github.com/rust-lang/crates.io/issues/3617'>GitHub issue #3617</a>.
    </p>

    <h2 id='api'><a href='#api'>crates.io API</a></h2>

    <p>
      crates.io provides an API that is a superset of the functionality required by the
      <a href='https://doc.rust-lang.org/cargo/reference/registry-web-api.html'>Cargo Web API</a>. An
      <a href='https://blog.rust-lang.org/2025/02/05/crates-io-development-update/#openapi-description'>experimental</a>
      OpenAPI description is available at
      <a href='https://crates.io/api/openapi.json'>https://crates.io/api/openapi.json</a>. Should you be unable to use
      one of the previous options, you are welcome to use the crates.io API provided you abide by the following limits:
    </p>

    <ol>
      <li>A maximum of 1 request per second, and</li>
      <li>
        A
        <code>user-agent</code>
        header that identifies your application. We strongly suggest providing a way for us to contact you (whether
        through a repository, or an e-mail address, or whatever is appropriate) so that we can reach out to work with
        you should there be issues.
      </li>
    </ol>

    <h2 id='questions'><a href='#questions'>Questions</a></h2>

    <p>
      If none of the above options suit your needs, please contact the crates.io team either at
      <a href='mailto:help@crates.io'>help@crates.io</a>, or by starting
      <a href='https://github.com/rust-lang/crates.io/discussions'>a discussion on GitHub</a>, and we'll be happy to
      discuss solutions that might exist outside of the above guidelines.
    </p>
  </TextContent>
</template>
